package com.sc.service.goods;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sc.dal.mapper.goods.GoodsSkuMapper;
import com.sc.dal.model.goods.GoodsSku;

/**
 * 商品规格服务实现
 * @author maoyongbin
 * @日期 Mar 30, 2017 6:35:48 PM
 */
@Service
public class GoodsSkuService {
	@Autowired
	private GoodsSkuMapper goodsSkuMapper;
	
	public int insert(GoodsSku goodsSku){
		int resultInt = goodsSkuMapper.insert(goodsSku);
		
		return resultInt;
	}

    public int updateByPrimaryKey(GoodsSku goodsSku){
    	int resultInt = goodsSkuMapper.updateByPrimaryKey(goodsSku);
		
		return resultInt;
    }
	
	/**
     * 根据商品id，查找商品的规格，只查规格名称和数量
     * @param goodsId
     * @return List<Map<String, Object>>
     */
    public List<Map<String, Object>> selectGoodsSku(String goodsId){
    	List<Map<String, Object>> skuMapList = this.goodsSkuMapper.selectGoodsSku(goodsId);
    	
    	return skuMapList;
    }
	
	public List<GoodsSku> selectList(String goodsId){
		List<GoodsSku> goodsSkuList = this.goodsSkuMapper.selectList(goodsId);
		
		return goodsSkuList;
	}
	
	public Map<String ,Object> selectGoodsSkuById(Map<String ,Object> map){
		Map<String ,Object> goodsSkuMap = this.goodsSkuMapper.selectGoodsSkuById(map);
		
		return goodsSkuMap;
	}
	
	/**
     * 根据参数，查找单个商品对应的规格
     * @param goodsSku
     * @return GoodsSku
     */
    public GoodsSku selectOneByParam(GoodsSku goodsSku){
    	GoodsSku resultGoodsSku = this.goodsSkuMapper.selectOneByParam(goodsSku);
    	
    	return resultGoodsSku;
    }
}
